using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;

namespace Pay.Service.AutoMapper
{
    public class TokenShopSubjectProductMapper : IStartupDto
    {
        private IMapperConfigurationExpression _cfg;
        public TokenShopSubjectProductMapper(IMapperConfigurationExpression cfg)
        {
            _cfg = cfg;
        }
        public void Execute()
        {
            Create();
        }
        protected virtual void Create()
        {
            _cfg.CreateMap<TokenShopSubjectProduct, token_shop_subject_product_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.subject_id, src => src.MapFrom(c => c.SubjectId))
                .ForMember(dest => dest.product_id, src => src.MapFrom(c => c.ProductId))
                .ForMember(dest => dest.sort, src => src.MapFrom(c => c.Sort))
                .ForMember(dest => dest.create_time, src => src.MapFrom(c => c.CreateTime))
                .ForMember(dest => dest.subject, src => src.MapFrom(c => c.Subject))
                .ForMember(dest => dest.product, src => src.MapFrom(c => c.Product));

            _cfg.CreateMap<token_shop_subject_product_dto, TokenShopSubjectProduct>()
                .ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
                .ForMember(dest => dest.SubjectId, src => src.MapFrom(c => c.subject_id))
                .ForMember(dest => dest.ProductId, src => src.MapFrom(c => c.product_id))
                .ForMember(dest => dest.Sort, src => src.MapFrom(c => c.sort))
                .ForMember(dest => dest.CreateTime, src => src.MapFrom(c => c.create_time))
                .ForMember(dest => dest.Subject, src => src.MapFrom(c => c.subject))
                .ForMember(dest => dest.Product, src => src.MapFrom(c => c.product));
        }
    }
}
